

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "MGConstFile.h"

typedef enum : NSUInteger {
    MyInputTypeMIMA=0,    // 密码
    MyInputTypeIDCARD,  // 身份证号码
} MyInputType;

@interface Util : NSObject

+ (Util*)sharedUIFactory;
//用户隐私显示隐藏 1身份证 全部隐藏  2房产证，不动产，字号 展示后四位  3姓名  只展示最后一个   4公司名  第四第五展示星星
+(NSString *)privacyManageString:(NSString *)str andType:(int)type;
//全角转半角
+(NSString *)quanToban:(NSString *)string;

#pragma mark - 快捷创建UI AlertView
//AlertView
+ (UIAlertView *)createAlertViewWithMessage:(NSString *)message;

+ (UIAlertView *)createAlertViewWithMessage:(NSString *)message
                                     cancel:(NSString *)cancel
                                       sure:(NSString *)sure
                                        tag:(NSInteger)tag
                                   delegate:(id)delegate;

+ (UIAlertView *)createAlertViewWithTitle:(NSString *)title
                                  message:(NSString *)message
                                   cancel:(NSString *)cancel
                                     sure:(NSString *)sure
                                      tag:(NSInteger)tag
                                 delegate:(id)delegate;


#pragma mark - 便捷方法 限制 格式
+ (NSArray *)provinceArr;
+ (BOOL)isAreaCode:(NSString *)province;
+ (NSString *)getStringWithRange:(NSString *)str Value1:(int)v1 Value2:(int)v2;
+ (BOOL)accurateVerifyIDCardNumber:(NSString *)value;
// 校验验证码

+ (BOOL)verifyIDCardNumber:(NSString *)IDCardNumber;


// 去掉UITextField空格字符
+(NSString *)deleteSpaceforTextField:(UITextField *)textfeild;



//限制textField不能输入的字符
+(BOOL)limitTextFieldCanNotInputWord:(NSString *)string limitStr:(NSString *)limitStr;

//限制textField输入的文字
+(BOOL)limitTextFieldInputWord:(NSString *)string limitStr:(NSString *)limitStr;

//保留2位小数
+(double)getTwoDecimalsDoubleValue:(double)number;

//判断输入的字符长度 一个汉字算2个字符
+ (NSUInteger)unicodeLengthOfString:(NSString *)text;

//字符串截到对应的长度包括中文 一个汉字算2个字符
+ (NSString *)subStringIncludeChinese:(NSString *)text ToLength:(NSUInteger)length;

//限制UITextField输入的长度，包括汉字  一个汉字算2个字符
+(void)limitIncludeChineseTextField:(UITextField *)textField Length:(NSUInteger)kMaxLength;


//限制UITextField输入的长度，不包括汉字
+(void)limitTextField:(UITextField *)textField Length:(NSUInteger)kMaxLength;


//// [0-9a-zA-Z]{0,18} 输入之前的值 string 输入的字符 ()
+ (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string andtype:(MyInputType )type;

//小数点前 kMaxLength 位，小数点后两位 仅限输入数字、1个小数点
+ (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string Length:(NSUInteger)kMaxLength;

//限制UITextView输入的长度，包括汉字  一个汉字算2个字符
+(void)limitIncludeChineseTextView:(UITextView *)textview Length:(NSUInteger)kMaxLength;

//限制UITextView输入的长度，不包括汉字
+(void)limitTextView:(UITextView *)textview Length:(NSUInteger)kMaxLength;

//电话号码转换
+(NSString *)getConcealPhoneNumber:(NSString *)phoneNum;




//获得应用版本号
+(NSString *)getApplicationVersion;

// add
+ (BOOL)isNumText:(NSString *)str;

// 是否是
+ (BOOL)isPureInt:(NSString*)string;

//add 首字符是否是英文开头
+ (BOOL)isEnglishFirst:(NSString *)string;

//add 获取app名字
+ (NSString *)getApplicationName;
// 限制标点空格
+(BOOL)limitSpecialSting:(NSString *)string;


#pragma mark - 倒计时按钮

// 开启倒计时效果 发送验证码
+(void)openCountdown:(UIButton *)authCodeBtn;




#pragma mark - 创建二维码 图片
// 字符串生成二维码
+ (UIImageView *)generatedQRCodeWithStr:(NSString *)str;

//保存图片
+ (void)loadImageFinished:(UIImage *)image;


#pragma mark - 快捷获取 与 调用
// 
+ (NSString *)deviceTokenString;                                //读取设备号

+ (void)showAppCommentWithAppID:(int)appID;                     //显示AppStore应用评论
+ (void)invokeVibration;                                        //震动

+ (void)callAtOnce:(NSString *)telephoneNum;                    //直接拨打电话
+(void)callOpenUrl:(NSString *)telephoneNum;                    //系统弹框拨打电话
+ (void)sendSMS:(NSString *)telephoneNum;                       //发送短信
+ (void)sendEmail:(NSString *)emailAddr;                        //发送邮件
+ (void)openUrl:(NSString *)url;                                //打开网页

+ (NSStringEncoding)getGBKEncoding;                             //获得中文gbk编码

+ (NSString *)getAvatarFilePath;

+ (void)statusWithStyle:(UIStatusBarStyle)style;



#pragma mark -- 相机、权限 --
//相机
+ (BOOL)isCameraAccessShowTips:(BOOL)show;
//相册
+ (BOOL)isAssetsLibraryAccessShowTips:(BOOL)show;
//通知是否开启
+ (BOOL)isMessageNotificationServiceOpen;
//进入消息通知设置
+(void)autoGo2NotificationsSetting;

#pragma mark --  JSON 解析 --
//解析json
+ (id)jsonWithData:(NSData *)data error:(NSError **)error;
//对象转 jsonData
+ (NSData *)jsonDataWithObject:(id)data error:(NSError **)error;
//获取json字符串
+ (NSString *)jsonStringWithObject:(id)data error:(NSError **)error;


#pragma mark - maskBorderAndRadiu
/**
 *  普通Button添加 border 和 圆边
 *
 *  @param maskView 需要处理的View
 */
+(void)maskBorderAndRadiu:(UIView *)maskView;

/**
 *  普通Button添加 border 和 圆边
 *
 *  @param maskView    需要处理的View
 *  @param borderColor 边框颜色
 */
+(void)maskBorderAndRadiu:(UIView *)maskView borderColor:(UIColor *)borderColor;

/**
 *  添加 border 和 圆边
 *
 *  @param maskView     需要处理的View
 *  @param color        边框颜色
 *  @param cornerRadius 圆角
 *  @param borderWidth  边框宽度
 */
+(void)maskBorderAndRadiu:(UIView *)maskView color:(UIColor *)color cornerRadius:(CGFloat)cornerRadius borderWidth:(CGFloat)borderWidth;


+(NSString *)getMGAuthenticationStatus:(MGAuthenticationStatus )Status;

+(NSString *)getMGOfficestatus:(MGOfficestatus )Status;

+(NSString *)getMGConsultFileStatus:(MGConsultFileStatus )Status;

+(NSString *)getMGConsultFileDealStatus:(MGConsultFileDealStatus )Status;
@end
